<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>添加资源</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

	<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
  </head>
  
  <body>
    <a style="float: left" href="<%=basePath%>resourcelist">资源列表</a>
    <center>
    添加资源. <br>
    
	    <form action="<%=basePath%>addResource" method="post" id="resourceform">
	    	<table>
	    		<tr>
	    			<td>资源名称：</td>
	    			<td><input maxlength="30" name="name" id="name" type="text" width="100px;"></td>
	    		</tr>
	    		<tr>
	    			<td>提交：</td>
	    			<td><input id="resourcebutton" type="button" width="100px;" value="提交"></td>
	    		</tr>
	    	</table>
	    	
	    	
	    </form>
    </center>
  </body>
  <script type="text/javascript">

	$("#resourcebutton").bind("click",function(){
		if($("#name").val()==""){
			alert("不填点什么?");
			return;
		}
		$(this).unbind("click");
	  	$.ajax({
		    type: "POST",
		    url: "/addResource",
		    dataType: 'text',
		    data:$('#resourceform').serialize(),
		    success: function(data){
		    	alert(data);
				location.reload();
		    }
		});	
	});
  </script>
</html>
